package com.cms.bean;

import java.util.ArrayList;
import java.util.List;

public class CategoryBean {
	private int id;
	private String name;
	private int typeId;
	private int parentId;
	private List<CategoryBean> childCategoryBeans;
	
	public CategoryBean(){
		childCategoryBeans = new ArrayList<CategoryBean>();
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getTypeId() {
		return typeId;
	}
	public void setTypeId(int typeId) {
		this.typeId = typeId;
	}
	public int getParentId() {
		return parentId;
	}
	public void setParentId(int parentId) {
		this.parentId = parentId;
	}
	public List<CategoryBean> getChildCategoryBeans() {
		return childCategoryBeans;
	}
	public void setChildCategoryBeans(List<CategoryBean> childCategoryBeans) {
		this.childCategoryBeans = childCategoryBeans;
	} 
    
	public CategoryBean getCategoryBeanById(int id) {
		if (this.id == id) {
			return this;
		}
		CategoryBean node = null;
		for (CategoryBean e : this.childCategoryBeans) {
			if (node != null)
				break;
			node = e.getCategoryBeanById(id);
		}
		return node;
	}
	
}
